<template>
    <div>
        姓名: <input type="text" v-model="name" placeholder="须于证件上的名字一致"> <br>
        手机号码: <input type="text" v-model="phone" placeholder="请填写手机号"> 用于接收取票信息和入园 <br>
        <input type="button" value="提交订单" @click="order">
    </div>
</template>

<script>
export default {
    data(){
        return {            
            name:'',
            phone:'',      
            g_id: this.$route.query.goods_id,      
        }
    },
    methods:{
        order(){
            // 验证手机号
            const reg = /^1[35789][0-9]{9}$/   //  \d
            if (!reg.test(this.phone)) {
                alert('手机号不对')                
            }
            const data = {
                user_id : sessionStorage.getItem('uid'),
                title:this.$route.query.title,
                price:this.$route.query.price,
                name:this.name,
                phone:this.phone,
            }

            this.axios.post('/order',data).then(resp=>{
                console.log(resp.data)
                alert('预定成功')
            }).catch(error=>{
                console.log(error)
            })

        }
    }

}
</script>

<style>

</style>